﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DomainModel;
using Utils;
using WebUI.Models;

namespace WebUI.Controllers
{
    public class SearchController : BaseController
    {
        public ActionResult Jobs(string tag)
        {
            return View(new JobsViewModel(tag));
        }

        public ActionResult Shots(int? page)
        {
            int pageNum = 1;
            if (page != null)
            {
                pageNum = page.Value;
            }
            if (pageNum > 30)
            {
                return RedirectToAction("Shots", new { Page = 1 });
            }
            else
            {
                return View(new ShotsViewModel(pageNum));
            }
        }

        public ActionResult Designers(DesignerSearchParamViewModel searchParam)
        {
            return View(new DesignersViewModel(searchParam));
        }

        [HttpPost]
        public ActionResult Designers(DesignersViewModel model)
        {
            DesignerSearchParamViewModel param = new DesignerSearchParamViewModel();
            if (model.AvailableForHire)
            {
                param.For_Hire = "on";
            }
            else {
                param.For_Hire = "off";
            }
            param.Page = "1";
            param.Location = model.Location;
            param.Skills = model.Skills;
            return RedirectToAction("Designers", param);
        }
    }
}
